//模糊查询OFFER_RECEIPT_TXT “%买一送一%”,再判断新零售是否等于CUSTOMER_DISC_AMT，
//前七天内的，小于就高风险；期间内的，不等于就报错
//如是则报错，新零售价格与买一送一折扣不一致，不可提交
var result_92 = JSON.parse('{"CODE":0, "ACTION":"","LEVEL":"", "MSG":"","DATA":"","RULE":"FS_92"}');

function checklinksave(list) {
    for (var i = 0; i < list.length; i++) {
        if (list[i].ITEM_NBR == ITEM_NBR
            && (list[i].OFFER_RECEIPT_TXT.indexOf('买一送一') >= 0 || list[i].OFFER_RECEIPT_TXT.indexOf('第2件5折') >= 0)) {
            //前七天内的
            if (betweenDay(addDate(new Date(list[i].OFFER_BEGIN_DATE), 7), EFF_DATE)>0
                && betweenDay(EFF_DATE, new Date(list[i].OFFER_END_DATE))>0
                || betweenDay(addDate(new Date(list[i].OFFER_BEGIN_DATE), 7), EXP_DATE)>0
                && betweenDay(EXP_DATE, new Date(list[i].OFFER_END_DATE))>0) {
                if (NEW_RETAIL < list[i].CUSTOMER_DISC_AMT) {
                    return 1;
                }
                //期间内的
                if (isDateIntersection(list[i].OFFER_BEGIN_DATE, list[i].OFFER_END_DATE, NEW_RETAIL_EFF_DATE, NEW_RETAIL_EXP_DATE)) {
                    if (NEW_RETAIL != list[i].CUSTOMER_DISC_AMT) {
                        return 2;
                    }
                }
            }
        }
    }
    return 0;
}

var list = !isNull(LINKSAVE) ? JSON.parse(LINKSAVE) : [];
if(!isNull(UPC_NBR) && UPC_NBR.toString().substr(0, 2) == '21'){
    if (checklinksave(list) == 1 && !inSuspendBP(ITEM_NBR,NEW_RETAIL_EFF_DATE,JSON_ITEM_LIST,ID)) {
        result_92.CODE = 1;
        result_92.ACTION = "APPROVAL_LEVEL";
        result_92.LEVEL = "AG";
        result_92.MSG = "与Linksave冲突的高风险变价，需GMM审批";
    }
    if (checklinksave(list) == 2) {
        result_92.CODE = 2;
        result_92.ACTION = "CHECKING_REPORT";
        result_92.MSG = "新零售价格与买一送一折扣不一致，不可提交";
    }
}

JSON.stringify(result_92);

